{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# 测试Redis\n",
    "\n",
    "> db0存kc1、kc2等用户的密钥(hash值)，仅AS访问\n",
    "db1表存ktg ，AS访问\n",
    "db2表存Kv服务器的密钥，TGS访问"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import redis\n",
    "\n",
    "r = redis.StrictRedis(host='124.222.90.52', port=6379, db=6, password=\"cug123456\")\n",
    "r.set(\"test_key\", \"test_value\")\n",
    "print(r.get(\"test_key\"))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 初始化Redis\n",
    "> 获取tgs和ss密码的hash并写入db1、db2"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "import redis\n",
    "import hash\n",
    "\n",
    "key_u01 = hash.encrypt(\"user111111\")\n",
    "print(key_u01)\n",
    "key_tgs = hash.encrypt(\"tgs123456\")\n",
    "print(key_tgs)\n",
    "key_ss = hash.encrypt(\"ss123456\")\n",
    "print(key_ss)\n",
    "\n",
    "r0 = redis.StrictRedis(host='124.222.90.52', port=6379, db=0, password=\"cug123456\")\n",
    "r0.set(\"u01\", key_u01)\n",
    "r1 = redis.StrictRedis(host='124.222.90.52', port=6379, db=1, password=\"cug123456\")\n",
    "r1.set(\"tgs\", key_tgs)\n",
    "r2 = redis.StrictRedis(host='124.222.90.52', port=6379, db=2, password=\"cug123456\")\n",
    "r2.set(\"ss\", key_ss)\n",
    "\n",
    "print(r0.get(\"u01\"))\n",
    "print(r1.get(\"tgs\"))\n",
    "print(r2.get(\"ss\"))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 测试as"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 模拟登陆"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 模拟请求tgt"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 测试tgs"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 请求ticket"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "network",
   "language": "python",
   "display_name": "network"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}